//
//  AddBalanceDetailsVC.m
//  OnionHome
//
//  Created by fengjie on 2019/9/14.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "AddBalanceDetailsVC.h"

@interface AddBalanceDetailsVC ()

@end

@implementation AddBalanceDetailsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColorFromRGB(0xF5F7F5);
    [self createUI];
}
-(void)setType:(AddBalanceType)type{
    _type = type;
    if (type == AddBalance) {
        self.title = @"充值详情";
    }else{
        self.title = @"提取详情";
    }
}
-(void)createUI{
    UIImageView * topImage = UIImageView.new;
    topImage.image = IMAGE_NAMED(@"me_ successful");
    topImage.layer.cornerRadius = 38;
    
    UILabel * topLabel = UILabel.new;
    topLabel.textColor = UIColorFromRGB(0x273323);
    topLabel.font = PingFangSC_Medium(22);
    
    if (self.type == AddBalance) {
        topLabel.text = @"充值成功";
    }else{
        topLabel.text = @"提取成功";
    }
    
    UIView * view = [self createView];
    
    UIButton * commitButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [commitButton setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0x009966)] forState:UIControlStateNormal];
    [commitButton setTitle:@"完成" forState:UIControlStateNormal];
    ViewRadius(commitButton, 5);
    commitButton.titleLabel.font = PingFangSC_Medium(18);

    kWeakSelf(weakSelf);
    [commitButton addActionHandler:^{
        [weakSelf.navigationController popToRootViewControllerAnimated:YES];
    }];

    
    [self.view addSubview:topImage];
    [self.view addSubview:topLabel];
    [self.view addSubview:view];
    [self.view addSubview:commitButton];
    
    [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(52);
        make.width.height.mas_equalTo(76);
    }];
    [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(topImage.mas_bottom).offset(20);
    }];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(topLabel.mas_bottom).offset(20);
        make.height.mas_equalTo(92);
    }];
    [commitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(40);
        make.right.mas_equalTo(-40);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(view.mas_bottom).offset(20);
    }];
}
-(UIView *)createView{
    UIView * view = UIView.new;
    view.backgroundColor = UIColor.whiteColor;
    
    UILabel * typeLabel = UILabel.new;
    typeLabel.textColor = UIColorFromRGB(0x959E97);
    typeLabel.font = SYSTEMFONT(16);
    typeLabel.text = @"微信支付";
    
    UILabel * amountlab = UILabel.new;
    amountlab.textColor = UIColorFromRGB(0x959E97);
    amountlab.font = SYSTEMFONT(16);
    amountlab.text = @"充值金额";
    
    UILabel * numberLb = UILabel.new;
    numberLb.textColor = UIColorFromRGB(0x273323);
    numberLb.font = PingFangSC_Medium(16);
    numberLb.text = @"￥5.00";

    [view addSubview:typeLabel];
    [view addSubview:amountlab];
    [view addSubview:numberLb];
    
    [typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(16);
    }];
    
    [amountlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(typeLabel.mas_bottom).offset(16);

    }];
    
    [numberLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(amountlab);
        make.right.mas_equalTo(-16);
    }];

    return view;
}
@end
